count the number of occurrences of a string